\section{compan --- Companion matrix}
\label{fn:compan}
\index{compan()}
\index{companion matrix}
\index{matrix!companion}
\begin{rail}
Companion : 'compan' '(' ( Scalar | Matrix ) ')' ;
\end{rail}

\verb+compan+ returns the companion matrix of the argument matrix.
If the argument is an (n+1)-vector, the companion matrix is $n x n$. If
the argument is a scalar, say $s$, then \verb+compan(s)+ is the 
$sxs$ matrix formed by taking the companion of $[1,2,\ldots, s+1]$. If
the argument is a matrix, but is not a vector, an internal conversion
to vector format is done.

$\Longrightarrow$ This is not an \RLaB\ built-in function.  This function
is normally loaded on start-up from the \verb+compan.r+ file in the
standard \verb+rlib+ directory. Use of the \verb+-r+ option, incorrectly 
setting the \verb+RLAB_LIB_DIR+ environmental variable, or modifying
\verb+compan.r+ may make this function unavailable.

\paragraph{Example}
\index{example of compan()}
\index{compan()!example}
\begin{verbatim}
> compan(1)
        1
> compan(2)
       -2         -3  
        1          0  
> compan(3)
       -2         -3         -4  
        1          0          0  
        0          1          0  
> compan([1,2])
        1
> compan([1,2,3])
       -2         -3  
        1          0  
> compan([2,3,5])
     -1.5       -2.5  
        1          0 
\end{verbatim}

\newpage





